package com.hxkcloud.patient.adapter;

import android.content.Context;
import android.util.DisplayMetrics;
import android.view.View;
import android.widget.TextView;

import com.nostra13.universalimageloader.core.ImageLoader;
import com.hxkcloud.patient.R;
import com.hxkcloud.patient.beans.ArticleBean;
import com.hxkcloud.patient.utils.ImageOptionUtils;
import com.hxkcloud.patient.views.RoundImageView;

import java.util.List;

/**
 * 健康资讯
 * Created by Administrator on 2016/12/27.
 */

public class InformationAdapter extends MyModelBaseAdapter<ArticleBean> {
    public InformationAdapter(List<ArticleBean> list, Context context, int resourceId) {
        super(list, context, resourceId);
        DisplayMetrics dm =context.getResources().getDisplayMetrics();
        screenWidth = dm.widthPixels;
    }
    private int screenWidth;
    @Override
    public void initView(View convertView, int position) {

        RoundImageView information_icon = (RoundImageView) convertView.findViewById(R.id.information_icon);
        TextView information_time = (TextView) convertView.findViewById(R.id.information_time);
        TextView information_title = (TextView) convertView.findViewById(R.id.information_title);
        TextView information_dsc = (TextView) convertView.findViewById(R.id.information_dsc);

    /*    RelativeLayout.LayoutParams lp_head = new RelativeLayout.LayoutParams(screenWidth / 6, screenWidth / 6);
        //lp_head.setMargins(20, 0, 0, 0);
        information_icon.setLayoutParams(lp_head);*/
        ImageLoader.getInstance().displayImage(getItem(position).getImg(), information_icon,
                ImageOptionUtils.getInstance().getArticlePicBigOptions(2));
        information_time.setText(getItem(position).getCreateTime());
        information_title.setText(getItem(position).getName());
        information_dsc.setText(getItem(position).getIntro());
    }
}
